﻿namespace Sidvall.Data
{
	public class Geometry
	{
		public int CoordinateSystemId { get; set; }
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
		public byte[] BinaryValue { get; set; }
		public string GmlValue { get; set; }
		public string TextValue { get; set; }

		public static Geometry Deserialize(string value)
		{
			if (string.IsNullOrWhiteSpace(value))
				return null;
			return null;
		}
		public string Serialize()
		{
			if (string.IsNullOrWhiteSpace(this.GmlValue))
				return this.CoordinateSystemId.ToString(System.Globalization.CultureInfo.InvariantCulture) + ".G." + this.GmlValue;
			if (string.IsNullOrWhiteSpace(this.TextValue))
				return this.CoordinateSystemId.ToString(System.Globalization.CultureInfo.InvariantCulture) + ".T." + this.TextValue;
			return null;
		}

		public static Geometry FromBinary(int coordinateSystemId, byte[] value)
		{
			Geometry item;

			item = new Geometry()
			{
				CoordinateSystemId = coordinateSystemId,
				BinaryValue = value
			};

			return item;
		}
		public static Geometry FromGml(int coordinateSystemId, string value)
		{
			Geometry item;

			item = new Geometry()
			{
				CoordinateSystemId = coordinateSystemId,
				GmlValue = value,
			};

			return item;
		}
		public static Geometry FromText(int coordinateSystemId, string value)
		{
			Geometry item;

			item = new Geometry()
			{
				CoordinateSystemId = coordinateSystemId,
				TextValue = value,
			};

			return item;
		}
	}
}
